<?php

/**
 * EFloatingMessage class
 * You must register EjQueryUiTheme too, otherwise the box will be transparent.
 *
 * @author Julot <andy.julot@gmail.com>
 * @since Tuesday, August 9, 2011. 09:22 PM
 */
class EFloatingMessage {

	public static function register() {
		$cs = Yii::app()->clientScript;
		$cs->registerCoreScript('jquery');
		$path = Yii::app()->extensionPath . '/EFloatingMessage/';
		$asset = Yii::app()->getAssetManager()->publish($path);
		$cs->registerScriptFile($asset . '/jquery.floatingmessage.js');
	}

	public static function add($message, $options=array(), $theme=false) {
		if ($theme) {
			EjQueryUiTheme::register($theme);
		}
		self::register();
		$opts = CJavaScript::encode($options);
		$script = '$.floatingMessage("' . $message . '", ' . $opts . ');';
		$cs = Yii::app()->clientScript;
		$cs->registerScript(__CLASS__, $script, CClientScript::POS_READY);
	}

}
